/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package controller;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import model.CostFunction;
import model.ProfitFunction;
import view.GrapicPanel;
import view.StartGUI;

/**
 *
 * @author Stupi
 */
public class Controller {
    
    private StartGUI startGUI;

    public Controller() {
    
        startGUI = new StartGUI();
        startGUI.setVisible(true);
        startGUI.addBtnCalculateListener(new CalculateListener());
        
        
    }
    
    class CalculateListener implements ActionListener {

        @Override
        public void actionPerformed(ActionEvent ae) {
            
     
            
            int fc = 0;
            int vc = 0;
            int pc = 0;
            
            try {
                
                fc = startGUI.getFixedCosts();
                vc = startGUI.getVarCosts();
                pc = startGUI.getPrice();
                
                
            } catch (Exception e) {
               startGUI.showMessage("Enter only integer values.");
               return;
            }
            
            CostFunction costF = new CostFunction();
            ProfitFunction profF = new ProfitFunction();
            
            
            costF.setFixedCosts(fc);
            costF.setVarCosts(vc);
            
            int startX1 = 1;
            costF.calculateYCostValue(startX1);
            int startY1 = costF.getCostYvalue();
            int endX1 = 400;
            costF.calculateYCostValue(endX1);
            int endY1 = costF.getCostYvalue();
            
            //treba da dodam jos za ProfitFunction vrednosti
            
            GrapicPanel graphicPnl = new GrapicPanel(startX1, startY1, endX1, endY1, 50, 50, 60, 60);
            
            graphicPnl.setVisible(true);
            
        }
        
    }
    
}
